package org.mat.ipaas.ucenter.service.api.system;

import com.alibaba.fastjson.JSONObject;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.mat.framework.lang.dto.MatApiResponse;

import org.mat.ipaas.ucenter.service.constant.CommonConstant;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysUserDTO;
import org.mat.ipaas.ucenter.service.dto.system.model.SysLoginModelDTO;
import org.mat.ipaas.ucenter.service.dto.system.vo.LoginUserDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * TODO fallback
 *
 * @Author scott
 * @since 2018-12-17
 */
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "login-rest-api")
public interface LoginRestAPI {

    @RequestMapping(value = "/sys/login-no-captcha", method = RequestMethod.POST)
    MatApiResponse<LoginUserDTO> loginWithoutCaptcha(@RequestParam("username") String username,
                                                     @RequestParam("password") String password);

    @RequestMapping(value = "/sys/login", method = RequestMethod.POST)
    MatApiResponse<JSONObject> login(@RequestBody SysLoginModelDTO sysLoginModel);


    /**
     * 【vue3专用】获取用户信息
     */
    @GetMapping("/sys/user/getUserInfo")
    MatApiResponse<JSONObject> getUserInfo(@RequestHeader("X-Access-Token") String accessToken,
                                           @RequestHeader(CommonConstant.VERSION) String version);

    /**
     * 退出登录
     *
     * @return
     */
    @RequestMapping(value = "/sys/logout")
    MatApiResponse<Object> logout();

    /**
     * 获取访问量
     *
     * @return
     */
    @GetMapping("/sys/loginfo")
    MatApiResponse<JSONObject> loginfo();

    /**
     * 获取访问量
     *
     * @return
     */
    @GetMapping("/sys/visitInfo")
    MatApiResponse<List<Map<String, Object>>> visitInfo();


    /**
     * 登陆成功选择用户当前部门
     *
     * @param user
     * @return
     */
    @RequestMapping(value = "/sys/selectDepart", method = RequestMethod.PUT)
    MatApiResponse<JSONObject> selectDepart(@RequestBody SysUserDTO user);

    /**
     * 短信登录接口
     *
     * @param jsonObject
     * @return
     */
    @PostMapping(value = "/sys/sms")
    MatApiResponse<String> sms(@RequestBody JSONObject jsonObject);


    /**
     * 手机号登录接口
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/sys/phoneLogin")
    MatApiResponse<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject);

    /**
     * 获取加密字符串
     *
     * @return
     */
    @GetMapping(value = "/sys/getEncryptedString")
    MatApiResponse<Map<String, String>> getEncryptedString();

    /**
     * 后台生成图形验证码 ：有效
     *
     * @param key
     */
    @GetMapping(value = "/sys/randomImage/{key}")
    MatApiResponse<String> randomImage(@PathVariable("key") String key);

    /**
     * 切换菜单表为vue3的表
     */
    @GetMapping(value = "/sys/switchVue3Menu")
    MatApiResponse<String> switchVue3Menu();

    /**
     * app登录
     *
     * @param sysLoginModel
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sys/mLogin", method = RequestMethod.POST)
    MatApiResponse<JSONObject> mLogin(@RequestBody SysLoginModelDTO sysLoginModel) throws Exception;

    /**
     * 图形验证码
     *
     * @param sysLoginModel
     * @return
     */
    @RequestMapping(value = "/sys/checkCaptcha", method = RequestMethod.POST)
    MatApiResponse<?> checkCaptcha(@RequestBody SysLoginModelDTO sysLoginModel);

    /**
     * 登录二维码
     */
    @GetMapping("/sys/getLoginQrcode")
    MatApiResponse<?> getLoginQrcode();

    /**
     * 扫码二维码
     */
    @PostMapping("/sys/scanLoginQrcode")
    MatApiResponse<?> scanLoginQrcode(@RequestParam String qrcodeId, @RequestParam String token);


    /**
     * 获取用户扫码后保存的token
     */
    @GetMapping("/sys/getQrcodeToken")
    MatApiResponse getQrcodeToken(@RequestParam String qrcodeId);

}